<?php


namespace app\controller;

use app\BaseController;
use \app\service\articleService;
use think\response\Json;
use think\Request;

class Article extends BaseController
{
    // 获取文章
    public function index(Request $request): Json
    {
        //查询参数
        $data = $request->get(['id', 'articleTypeId']);
        //分页参数
        $page = $request->get(['list_rows', 'page']);
        //时间查询参数
        $queryTime = $request->get(['issueTime']);

        return articleService::getArticle($data, $page, $queryTime);
    }

    //更新添加文章
    public function updateArticle(): Json
    {
        $data = request()->post();
        return articleService::addAndUpdateArticle($data);
    }

    // 点赞文章
    public function articleLike():Json
    {
        $data = request()->post();
        return articleService::Link($data);
    }

    // 文章收藏
    public function articleCollect():Json
    {
        $data = request()->post();
        return articleService::collect($data);
    }
}